package cn.tedu.charging.user.controller;

import cn.tedu.charging.common.pojo.JsonResult;
import cn.tedu.charging.common.pojo.vo.UserInfoVO;
import cn.tedu.charging.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("user")
@Api(tags = "用户模块")
public class UserController {

    //@Resource 八股文的面试题 理解他们之间的区别
    @Autowired
    private UserService userService;

    @ApiOperation("获取用户信息")
    @GetMapping("/info/{userId}")
    public JsonResult<UserInfoVO> getUserInfo(@PathVariable("userId") Integer userId){
        log.debug("获取用户信息-入参:{}",userId);
        log.debug("获取用户信息-userService-入参:{}",userId);
        UserInfoVO userInfoVO = userService.getUserInfo(userId);
        log.debug("获取用户信息-userService-入参:{},出参:{}",userId,userInfoVO);

   /*     JsonResult<UserInfoVO> jsonResult = new JsonResult<>();
        jsonResult.setData(userInfoVO);
        jsonResult.setCode(2000);
        jsonResult.setMessage("获取用户信息成功");
        */
        JsonResult<UserInfoVO> jsonResult =
                JsonResult.ok(userInfoVO,"获取用户信息成功");
        log.debug("获取用户信息-入参:{},-出参:{}",userId,jsonResult);

        return jsonResult;
    }

}
